package com.koron.order.question.bean.po;


import com.koron.bean.base.BaseBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 重大问题上报单(Question)实体类
 *
 * @author zhouj
 * @since 2022-01-14 10:15:28
 */
@Data
@ApiModel("重大问题上报单")
public class QuestionPo extends BaseBean implements Serializable {

    @ApiModelProperty(value = "重大问题上报工单编码")
    private String code;

    @ApiModelProperty(value = "重大问题上报工单标题")
    private String title;

    @ApiModelProperty(value = "关联工单id")
    private String orderId;

    @ApiModelProperty(value = "关联工单类型")
    private String orderType;

    @NotBlank
    @ApiModelProperty(value = "关联工单编号")
    private String orderCode;

    @ApiModelProperty(value = "专业(自动加载工单的专业)")
    private String major;

    @ApiModelProperty(value = "设备ID")
    private String equipmentId;

    @ApiModelProperty(value = "设备名称")
    private String equipmentName;

    @NotBlank
    @ApiModelProperty(value = "设备管理单位ID")
    private String deptManage;

    @NotBlank
    @ApiModelProperty(value = "设备管理单位名称")
    private String deptManageName;

    @NotBlank
    @ApiModelProperty(value = "设备管理单位负责人账号")
    private String leader;

    @NotBlank
    @ApiModelProperty(value = "设备管理单位负责人名字")
    private String leaderName;

    @NotBlank
    @ApiModelProperty(value = "问题描述")
    private String question;

    @NotBlank
    @ApiModelProperty(value = "原因分析")
    private String reason;

    @NotBlank
    @ApiModelProperty(value = "处理意见")
    private String suggest;

    @ApiModelProperty(value = "联系人id")
    private String contactId;

    @NotBlank
    @ApiModelProperty(value = "联系人名称")
    private String contactName;

    @ApiModelProperty(value = "联系人所属单位ID")
    private String contactDeptId;

    @ApiModelProperty(value = "联系人所属单位名称")
    private String contactDeptName;

    @ApiModelProperty(value = "联系人类别")
    private String contactType;

    @NotBlank
    @ApiModelProperty(value = "联系电话")
    private String phone;

    @NotBlank
    @ApiModelProperty(value = "申请人所属单位ID")
    private String deptId;

    @NotBlank
    @ApiModelProperty(value = "申请人所属单位名称")
    private String deptName;

    @ApiModelProperty(value = "文件清单")
    private List<String> files;

    @ApiModelProperty(value = "工单状态")
    private String status;

    @ApiModelProperty(hidden = true)
    private String file;

    @ApiModelProperty(value = "是否有权限保存、提交;规则：草稿只能由创建人保存、提交。")
    private boolean hasSubmitPermission;

    public List<String> getFiles() {
        if (Objects.nonNull(file)){
            files = Arrays.asList(file.split(","));
        }
        return files;
    }
}